using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rocket : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject explosion;
    private Enemy enemy;
    void Start()
    {
        Destroy(gameObject, 2);
        //enemy=
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(explosion !=null)
        {
            if(collision.tag != "Player")
            {
                Quaternion rotation = Quaternion.Euler(0, 0, Random.Range(-30, 30));
                Instantiate(explosion, transform.position, rotation);
                Destroy(gameObject);
                if(collision.tag == "Enemy")
                {
                    collision.GetComponent<Enemy>().Hurt();
                }
            }

        }
    }
}
